﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BeniBastanYaratProject.Yonetim
{
    public partial class MarkaDuzenle : System.Web.UI.Page
    {

        DBBaglantiDataContext db = new DBBaglantiDataContext();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.Request["mid"] != null) {

                int markaid = int.Parse(Page.Request["mid"]);
                var sorgu = (from x in db.Markalars where x.MarkaID == markaid select x).SingleOrDefault();

                txtFirmaAdi.Text = sorgu.MarkaFirmaAdi;
                txtFirmaAdresi.Text = sorgu.MarkaFirmaAdresi;
                txtFirmaEposta.Text = sorgu.MarkaFirmaEposta;
                txtFirmaFax.Text = sorgu.MarkaFirmaFax;
                txtFirmaNot.Text = sorgu.MarkaFirmaNot;
                txtFirmaTel.Text = sorgu.MarkaFirmaTelefon01;
                txtFirmaTel2.Text = sorgu.MarkaFirmaTelefon02;
                txtFirmaTel3.Text = sorgu.MarkaFirmaTelefon03;
                txtFirmaYetkili.Text = sorgu.MarkaFirmaYetkili;
                ViewState["markaid"] = markaid;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            int markaid = int.Parse(ViewState["markaid"].ToString());

            var sorgu = (from x in db.Markalars where x.MarkaID == markaid select x).SingleOrDefault();

            sorgu.MarkaFirmaAdi = txtFirmaAdi.Text;
            sorgu.MarkaFirmaAdresi = txtFirmaAdresi.Text;
            sorgu.MarkaFirmaEposta = txtFirmaEposta.Text;
            sorgu.MarkaFirmaFax = txtFirmaFax.Text;
            sorgu.MarkaFirmaNot = txtFirmaNot.Text;
            sorgu.MarkaFirmaTelefon01 = txtFirmaTel.Text;
            sorgu.MarkaFirmaTelefon02 = txtFirmaTel2.Text;
            sorgu.MarkaFirmaTelefon03 = txtFirmaTel3.Text;
            sorgu.MarkaFirmaYetkili = txtFirmaYetkili.Text;

            db.SubmitChanges();

            Response.Redirect("MarkaIslemleri.aspx");
        }
    }
}